<!DOCTYPE html>
<html>

<head>
    <title>{$category.name} {$category.seo_title} {$site_info.site_name|default=''}</title>
    <meta name="keywords" content="{$category.seo_keywords},{$site_info.site_seo_keywords|default=''}" />
    <meta name="description" content="{$category.seo_description},{$site_info.site_seo_description|default=''}">
    <include file="public@head" />
    <hook name="before_head_end" />
</head>

<body class="bg-light">
    <include file="public@nav" />
    <empty name="$category">
        <section class="">
            <h6 class="m-3 text-dark font-weight-bold">
                所有分类 
                <a class="float-right font-weight-light" href="{:cmf_url('portal/article/add')}"><i class="fa fa-edit"></i> 发表新话题</a>
            </h6>
            <portal:categories item="vo" order="list_order ASC">
                <div class="card mb-3 border-0" onclick='window.location.href="{:cmf_url('portal/List/index',array('id'=>$vo.id))}"'>
                    <div class="card-body">
                        <div class="media">
                            <empty name="$vo.more.thumbnail">
                                <img src="/assets/dist/images/default-thumbnail.png" style="width:54px;" class="mr-3 rounded" alt="{$vo.name}">
                                <else/>
                                <img src="{:cmf_get_image_url($vo.more.thumbnail)}" style="width:54px;" class="mr-3 img-fluid rounded" alt="{$vo.name}">
                            </empty>
                            <div class="media-body">
                                <h6 class="">{$vo.name}</h6>
                                <p class="mb-0">{$vo.description}</p>
                            </div>
                        </div>
                    </div>
                    <!-- <div class="card-footer bg-white text-muted">帖子数：{$vo.post_count}</div> -->
                </div>
            </portal:categories>
        </section>
        <else/>
        <section class="bg-primary py-4">
            <div class="container">
                <div class="text-center text-white">
                    <h6>{$category.name}</h6>
                    <p><small>{$category.description}</small></p>
                    <!-- <small>帖子 {$category.post_count} 篇</small> -->
                </div>
            </div>
        </section>
        <div class="container">
            <div class="row py-2">
                <div class="col">
                    <div class="dropdown">
                        <a class="btn btn-sm btn-primary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-navicon"></i></a>
                        <div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
                            <portal:categories item="vo">
                                <li data-id="8" class="dropdown-item pt-3 clearfix">
                                    <a href="{:cmf_url('portal/List/index',array('id'=>$vo.id))}" class="<if condition=" $category.id eq $vo.id ">active text-info font-weight-bold<else/>text-dark</if> ">
                                        <empty name="$vo.more.thumbnail">
                                            <img src="/assets/dist/images/default-thumbnail.png" style="width:24px;" class="rounded" alt="{$vo.name}">
                                            <else/>
                                            <img src="{:cmf_get_image_url($vo.more.thumbnail)}" style="width:24px;" class="img-fluid rounded" alt="{$vo.name}">
                                        </empty>
                                        <span class="mx-3" style="position:absolute;margin-top:1px;">{$vo.name}</span></a>
                                </li>
                            </portal:categories>
                        </div>
                    </div>
                </div>
                <div class="col text-right">
                    <a href="{:cmf_url('portal/article/add')}" class="btn btn-sm btn-primary"><i class="fa fa-edit"></i> 发表新话题</a>
                </div>
            </div>
        </div>
        <div class="card border-0">
            <div class="card-body p-2">
                <php>
                    $where=[ 'post.create_time'=>['egt',0] ];
                </php>
                <ul class="list-unstyled">
                    <portal:articles order="post.published_time DESC" relation="categories" page="10" where="$where" order="post.create_time DESC" categoryIds="$category.id">
                        <li class="media" onclick='window.location.href="{:cmf_url('portal/Article/index',array('id'=>$vo.id,'cid'=>$vo.category_id))}"'>
                            <div style="width: 42px;" class="mr-3">
                                <empty name="$vo.user.avatar">
                                    <img src="/assets/dist/images/headicon_128.png" class="img-fluid rounded-circle" alt="{$vo.post_title}">
                                    <else/>
                                    <img src="{:cmf_get_user_avatar_url($vo.user.avatar)}" class="img-fluid rounded-circle" alt="{$vo.post_title}">
                                </empty>
                            </div>
                            <div class="media-body">
                                <h6 class="mt-0 mb-1">
                                            <a class="text-dark" href="{:cmf_url('portal/Article/index',array('id'=>$vo.id,'cid'=>$vo.category_id))}">{$vo.post_title}</a>
                                        </h6>
                                <p class="text-muted">
                                    <empty name="$vo.user.user_nickname">
                                        {$vo.user.user_login}
                                        <else/> {$vo.user.user_nickname}
                                    </empty> 发布于 {:func_friendly_time($vo.published_time)}
                                    <foreach name="$vo.categories" item="cat">
                                        <span class="badge badge-info float-right">{$cat.name}</span>
                                    </foreach>
                                </p>
                                <blockquote style="word-break: break-word;">
                                    <php>
                                        $post_excerpt = str_replace("\n", "", strip_tags($vo['post_content'])); $post_excerpt = msubstr($post_excerpt,0,120);
                                    </php>
                                    {$post_excerpt}
                                </blockquote>
                            </div>
                        </li>
                        <hr style="border-top: 1px solid #f5f6f7; " class="nopadding py-2">
                    </portal:articles>
                </ul>
                <ul class="pagination mx-auto mb-0">
                    <page/>
                </ul>
            </div>
        </div>
        </section>
    </empty>
    <include file="public@footer" />
    <include file="public@scripts" />
</body>

</html>